Processing primitives which have unresolved fragments in a graphics processing system

ABSTRACT

A graphics processing system performs hidden surface removal and texturing/shading on fragments of primitives. The system includes a primary depth buffer (PDB) for storing depth values of resolved fragments, and a secondary depth buffer (SDB) for storing depth values of unresolved fragments. Incoming fragments are depth tested against depth values from either the PDB or the SDB. When a fragment passes a depth test, its depth value is stored in the PDB if it is a resolved fragment (e.g. if it is opaque or translucent), and its depth value is stored in the SDB if it is an unresolved fragment (e.g. if it is a punch through fragment). This provides more opportunities for subsequent opaque objects to overwrite punch through fragments which passed a depth test, thereby reducing unnecessary processing and time which may be spent on fragments which ultimately will not contribute to the final rendered image.

BACKGROUND

Graphics processing systems are used to process graphics data in orderto render images. As part of the processing performed by a graphicsprocessing system, primitives of objects in a three-dimensional sceneare processed to determine which of the primitives are visible at eachsample position of a rendering space of the graphics processing system,and to determine the appearance of the visible primitives at the samplepositions. In some examples, a single sample position may correspond toa pixel position of the final rendered image, but in other examples,more than one (e.g. four) sample positions may correspond to each pixelposition. Two stages of a typical graphics processing system are: (i)hidden surface removal (HSR), in which surfaces which are hidden byother surfaces in a scene are removed, and (ii) texturing and/or shadingin which a surface of an object is given a suitable appearance. In adeferred rendering graphics processing system the hidden surface removalstage is implemented before the texturing/shading stage.

An example of part of a deferred rendering graphics processing system100 is shown in FIG. 1. The system 100 comprises a graphics processingunit (GPU) 102 comprising a HSR module 104, and a fragment processingmodule 106 for performing texturing and/or shading on fragments ofprimitives. As a matter of terminology, a “fragment” is an element of aprimitive at a sample position. The system 100 also comprises a memory108 which is arranged to provide primitives to the GPU 102 and toreceive processed pixels from the GPU 102. The HSR module 104 comprisesdepth testing logic 110, a depth buffer 112 and a tag buffer 114. In thedeferred rendering system 100, the HSR module 104 is arranged to receivethe primitives from the memory 108. The depth buffer 112 stores depthvalues for an array of sample positions to indicate the current depth ateach sample position. The depth testing logic 110 uses the depth valuesstored in the depth buffer 112 to perform depth tests for incomingfragments to determine if the fragments are hidden by previouslyprocessed fragments. If the incoming fragments are not hidden then theappropriate depth values in the depth buffer 112 can be updated toreflect the depth of the incoming fragments. Fragments associated withan opaque object type or a translucent object type are resolvedfragments, in the sense that the presence and/or depth values of thesefragments will not be altered by the fragment processing module 106. Asdescribed below, the “presence” referred to here is presence in theprimitive, rather than for example presence in a final image, whereother factors, such as occlusion, may apply. Therefore, if the incomingfragments are opaque or translucent then the depth testing logic 110will use the depth values of incoming fragments (which pass the depthtest) to overwrite the depth values in the depth buffer 112. If theincoming fragments are opaque then the overwritten fragments can bediscarded since they will not contribute to the final rendered image.However, if the incoming fragments are translucent then the overwrittenfragments might still contribute to the final rendered image. Therefore,translucent fragments are processed such that a new translucent fragmentvalue is combined with a previous fragment value using a blendingequation that is indicated by the application. Typically the blendingequation is implemented in the fragment processing module 106 and usesan alpha value that is sourced from a texture in order to determine howtransparent the fragment is, in a process referred to as “alphablending”.

Other types of objects may include unresolved fragments. Fragment may be“unresolved” if the presence and/or depth values of the fragments may bealtered by the fragment processing module 106. For example, fragmentsgenerated when a punch through object type arrives at the HSR module 104are, initially, unresolved fragments because their presence is yet to beresolved by the fragment processing module 106. A primitive with a punchthrough object type may have holes (i.e. transparent areas) which aredetermined by texturing and shading operations. A fragment is said to bepresent in a primitive if it corresponds to an opaque area of theprimitive, and not to be present if it corresponds to a transparent areaof the primitive. Punch through object types should be processed by theHSR module such that it is possible to see through the holes left afterthe removal of any fragments that are determined not to be present. If apunch through fragment passes an initial depth test (based on comparingits depth value with the corresponding depth value in the depth buffer112) then the punch through fragment is forwarded to the fragmentprocessing module 106, but at that point the depth value in the depthbuffer 112 is not updated, because the depth buffer 112 is arranged tohold only depth values for resolved fragments (i.e. depth values whichwill not be altered or invalidated by feedback from the fragmentprocessing module 106) to ensure that the results of the depth tests areaccurate. The fragment processing module 106 processes punch throughfragments by performing a test (which may be referred to as an “alphatest”) which indicates whether a fragment is “present” i.e. is part ofthe primitive, or not. In this way, the fragment processing module 106resolves the presence of the punch through fragments. The alpha test fora fragment uses an alpha value that may be sourced from a texture inorder to determine whether the fragment is present or not. The result ofthis test is fed back to the depth testing logic 110, as shown by the“feedback” in FIG. 1. If a fragment is determined not to be present(i.e. if the fragment fails the alpha test) then no depth value iswritten to the depth buffer 112 for that fragment. However, if thefragment is determined to be present (i.e. if the fragment passes thealpha test) then the feedback to the depth testing logic 110 indicatesthat the presence of the fragment has been resolved, such that thefragment may now be treated as a resolved fragment. The depth testinglogic 110 can then update the depth buffer 112 with the depth value ofthe punch through fragment.

FIG. 1 shows that the tag buffer 114 is situated at the interfacebetween the depth testing logic 110 and the fragment processing module106. Tags are primitive identifiers which associate a fragment with theprimitive of which it is a part, and which allow attributes such astexturing and shading data for the primitive to be fetched whenrequired. The tag buffer 114 is used to hold tags for fragments from thefront most primitives (e.g. those fragments which pass the depth test)for each sample position in the part of the rendering space currentlybeing processed (e.g. in a tile when the system 100 is a tile-basedsystem). Tags for opaque fragments which pass the depth tests aretypically written into the tag buffer 114 even if they overwrite anexisting tag as that corresponds to the correct operation to processopaque fragments, as described above. Fragments from translucent andpunch through primitives may need to be combined with fragments thatthey overdraw. The combining of these fragments typically must beperformed in the order that they were submitted by the application. Assuch, whenever translucent or punch through fragments are found to liein front of fragments currently stored within the tag buffer 114, theHSR module 104 flushes currently visible tags to the fragment processingmodule 106. As described above, in the case of punch through fragments,the presence of fragments, and hence whether their depth values shouldbe updated in the depth buffer 112, is determined by the fragmentprocessing module 106. Therefore, tags for punch through primitives mustalso be flushed directly after any tags currently stored within the tagbuffer 114 have been flushed. It is noted that the combination of a tagand a position in the tag buffer 114 defines a fragment, so the flushingof tags from the tag buffer 114 can be considered to be flushingfragments from the tag buffer 114. Conceptually, it makes sense toconsider fragments being stored in the tag buffer 114 and fragmentsbeing flushed out to the fragment processing module 106. In a practicalimplementation, this conceptual flow of fragments is embodied by storingtags in the tag buffer 114 and flushing tags from the tag buffer 114.

It can be appreciated that in deferred rendering systems, such as system100, objects with unresolved fragments (e.g. punch through objects) canaffect the efficiency of the system. For example, when fragments of apunch through object are encountered the HSR module 104 cannot updatethe depth buffer 112 with the fragments' depth values until such time asit has received feedback from the fragment processing module 106, i.e.until the presence of the fragments has been resolved. This may have anumber of detrimental consequences, such as:

-   -   punch through fragments that are subsequently overdrawn by        opaque fragments may be unnecessarily shaded by the fragment        processing module 106 even though they will not contribute to        the final rendered image, hence there is unnecessary processing        being performed by the GPU 102;    -   opaque fragments which follow punch through fragments cannot be        processed until the results for the punch through fragments have        been returned from the fragment processing module 106 to the HSR        module 104, so there may be a stall in the processing while the        depth values of the punch through fragments are resolved; and    -   when the feedback is received at the HSR module 104 from the        fragment processing module 106, the depth values for the punch        through fragments that have been determined to be present need        to be re-calculated so that the depth buffer 112 can be updated        correctly.

SUMMARY

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

There is provided a graphics processing system comprising: a first depthbuffer configured to store depth values for resolved fragments for aplurality of sample positions within a rendering space of the graphicsprocessing system; a second depth buffer configured to store depthvalues for unresolved fragments for the sample positions; and depthtesting logic configured to receive primitive data relating toprimitives and to perform depth tests on fragments of the primitivesusing depth values stored in at least one of the depth buffers; whereinthe graphics processing system is configured to: (i) store, in the firstdepth buffer, the depth value of a fragment which passes a depth test ifthe fragment is a resolved fragment, and (ii) store, in the second depthbuffer, the depth value of a fragment which passes a depth test if thefragment is an unresolved fragment.

There is also provided a method of processing primitives in a graphicsprocessing system which comprises a first depth buffer configured tostore depth values for resolved fragments for a plurality of samplepositions within a rendering space of the graphics processing system,and a second depth buffer configured to store depth values forunresolved fragments for the sample positions, the method comprising:receiving primitive data relating to primitives at depth testing logicof the graphics processing system; performing depth tests on fragmentsof the primitives using depth values stored in at least one of the depthbuffers; and storing the depth value of a fragment which passes a depthtest in one of the depth buffers wherein, if the fragment is a resolvedfragment then the depth value of the fragment is stored in the firstdepth buffer, and if the fragment is an unresolved fragment then thedepth value of the fragment is stored in the second depth buffer.

There may also be provided computer readable code adapted to perform thesteps of any of the methods described herein when the code is run on acomputer. There may also be provided computer readable code forgenerating the graphics processing system of any of the examplesdescribed herein. The computer readable code may be encoded on acomputer readable storage medium.

The above features may be combined as appropriate, as would be apparentto a skilled person, and may be combined with any of the aspects of theexamples described herein.

BRIEF DESCRIPTION OF THE DRAWINGS

Examples will now be described in detail with reference to theaccompanying drawings in which:

FIG. 1 is a schematic diagram of part of a graphics processing system ofthe prior art;

FIG. 2 is a schematic diagram of part of a graphics processing systemimplementing two depth buffers;

FIGS. 3a and 3b show a flow chart illustrating a method of processingprimitives in a graphics processing system;

FIG. 4 represents the depth values of first and second depth buffers aswell as depth values of incoming primitives for a column of 32 samplepositions in part of a rendering space; and

FIG. 5 shows an integrated circuit manufacturing system for generatingan integrated circuit embodying a graphics processing system.

The accompanying drawings illustrate various examples. The skilledperson will appreciate that the illustrated element boundaries (e.g.,boxes, groups of boxes, or other shapes) in the drawings represent oneexample of the boundaries. It may be that in some examples, one elementmay be designed as multiple elements or that multiple elements may bedesigned as one element. Common reference numerals are used throughoutthe figures, where appropriate, to indicate similar features.

DETAILED DESCRIPTION

The inventor has realised that the efficiency with which a deferredrendering system processes objects with unresolved fragments (e.g. punchthrough objects) can be improved by using two depth buffers. Inparticular, a first depth buffer (which may be referred to herein as aprimary depth buffer or PDB) is provided for storing depth values forresolved fragments, and a second depth buffer (which may be referred toherein as a secondary depth buffer or SDB) is provided for storing depthvalues for unresolved fragments. When a fragment passes a depth test,its depth value may be stored in the PDB if the fragment is a resolvedfragment, and its depth value may be stored in the SDB if the fragmentis an unresolved fragment. This may, for example, provide moreopportunities for subsequent opaque objects to overwrite punch throughfragments which passed a depth test, thereby reducing unnecessaryprocessing which is performed on fragments which ultimately will notcontribute to the final rendered image. As another example,recalculation of depth values for fragments which pass an alpha test maybe avoided because the SDB stores the depth values of punch throughfragments which are forwarded for alpha testing such that if thefragments pass the alpha test, the SDB may already have their depthvalues stored, and can use those (now resolved) depth values to updatethe PDB.

A fragment may be “unresolved” for different reasons. For example, afragment may be unresolved if one or more of: (i) the depth of thefragment is not resolved, (ii) the presence of the fragment is notresolved, or (iii) the visibility of the fragment is not resolved. Forexample, an output-depth fragment (which may also be referred to as an“o-depth” fragment) is a fragment whose depth values can be altered bythe texturing/shading process of a fragment shader. That is, o-depthfragments have shader-dependent depth values. In other words, o-depthfragments have unresolved depth values until a fragment processingmodule has resolved their depth values. As another example, thefragments of a punch through object have unresolved presence until analpha test is performed (e.g. by a fragment processing module) toresolve their presence. As another example, which is described in moredetail below, the visibility of a fragment may be unresolved if thedepth value or presence of a previous fragment, which is located at thesame sample position, is unresolved. In this case the visibility of thefragment cannot be resolved until the depth value or presence of theprevious fragment has been resolved.

In contrast, a fragment may be “resolved” if its depth, presence andvisibility are all resolved. For example, fragments associated with anopaque object type or a translucent object type are resolved fragmentsunless the visibility of the fragment is not resolved. In scenesconsisting entirely of opaque and translucent objects, and without punchthrough or o-depth objects, all fragments are resolved.

Embodiments will now be described by way of example only.

FIG. 2 shows an example of a graphics processing system 200 whichcomprises a GPU 202 and a memory 208. The GPU 202 includes a HSR module204 configured to perform hidden surface removal on primitives, and afragment processing module 206 configured to perform one or both ofshading and texturing on fragments. The graphics processing system 200is a deferred rendering system in the sense that the fragment processingmodule 206 is arranged to act on fragments after the HSR module 204. Thememory 208 is arranged to provide primitives to the GPU 202 and toreceive processed pixels from the GPU 202. The HSR module 204 comprisesdepth testing logic 210, a first depth buffer 212 (which is referred toherein as a primary depth buffer or “PDB”), a set of three tag buffers214 ₁, 214 ₂ and 214 ₃, a second depth buffer 216 (which is referred toherein as a secondary depth buffer or “SDB”) and a store for storing aset of indicators 218 which, as described in more detail below, indicatewhich of the depth buffers to use for depth tests in the HSR module 204.In the deferred rendering system 200, the HSR module 204 is arranged toreceive the primitives from the memory 208, the fragment processingmodule 206 is arranged to receive texture data from the memory 208 andto provide processed pixel values to the memory 208.

The HSR module 204 maintains the PDB 212 and the SDB 216 such that thePDB 212 holds the current fully resolved depth values for samplepositions of a rendering space, and the SDB 216 contains the front-mostdepth values of unresolved fragments (e.g. associated with punch throughobjects) for the sample positions of the rendering space, where thosefragments have passed a depth test and have not currently beenoverdrawn. The PDB 212 and the SDB 216 store depth values for the samesample positions of the rendering space. For example, if the system 200is a tile-based graphics system then the rendering space for rendering awhole image is divided into a plurality of blocks or “tiles”, which aretypically rectangular and may for example each include a 32×32 block ofsample positions. Tiles may be other sizes and/or shapes, for exampleseach tile may include a block of 16×16 or 32×16 sample positions. Intile-based graphics systems, the PDB 212 and SDB 216 may store depthvalues corresponding to one tile within the rendering space. In otherexamples, the graphics processing system is not tile-based, in whichcase the PDB 212 and SDB 216 may store depth values corresponding to thewhole rendering space used to render an image.

The use of the secondary depth buffer 216 to store depth values forunresolved fragments, e.g. for punch through fragments which have passeda depth test, means that it is possible for subsequent objects to betested against the depth values of the punch through fragments and forthe punch through fragments to potentially be discarded if they areoverdrawn by opaque fragments, and this is achieved without needing tosubmit the punch through fragments to the fragment processing module206.

The operation of the graphics processing system 200 for processingprimitives is described below with reference to the flow chart shown inFIG. 3.

In step S302 primitives are received at the depth testing logic 210 fromthe memory 208. The primitives which are received at the depth testinglogic 210 may be in any suitable space for rasterization, such asscreen-space for rendering an image, or shadow map space for rendering ashadow map. For example, it may be the case that previous operationshave been performed in the system 200 in order to determine theprimitives in screen-space. Furthermore, prior to step S302, if thegraphics processing system 200 is a tile-based system then a tilingoperation may have been performed to determine which primitives arerelevant for which tiles, whereby the primitives for one tile may beprovided to the depth testing logic 210, then the primitives for anothertile may be provided to the depth testing logic 210, and so on. Theactual data describing the primitives which is passed from the memory208 to the depth testing logic 210 might not include all of the datarelating to a primitive, and may for example include the positional dataof the primitives (e.g. the screen-space positions of vertices of theprimitives) but might not include the texture or shading data for theprimitive. Even though some of the data for the primitives might not bepassed from the memory 208 to the HSR module 204, conceptually it makessense to think of the primitives being passed from the memory 208 to thedepth testing logic 210.

The indicators 218 indicate, for each of the sample positions of therendering space (e.g. each sample position of a current tile), which ofthe depth buffers the depth testing logic 210 is to use for performing adepth test. For example, each of the indicators may be associated with arespective one of the sample positions. For example, each indicator maybe a flag which indicates either the PDB 212 or the SDB 216. In thisexample, each indicator represents one of two possible options and assuch can be represented with a binary flag. The system 200 initialisesthe indicators 218 to indicate the PDB 212 for each sample position ofthe rendering space before any primitive data relating to primitives inthe rendering space is received at the HSR module 204.

In step S304, for a fragment of a received primitive, the depth testinglogic 210 uses the appropriate one of the indicators 218 to determinewhether the PDB 212 or the SDB 216 should be used for the depth test onthe fragment. In examples described herein, the indicator 218 indicatesthe PDB 212 when the front-most depth at a particular sample position isstored in the PDB and is that of a resolved fragment, whereas theindicator 218 indicates the SDB 216 when the front-most depth at theparticular sample position is stored in the SDB and is the depth of afragment that is yet to be resolved.

If the indicator indicates the PDB 212, then the method passes from stepS304 to S306 in which the depth testing logic 210 performs a depth teston the fragment using the appropriate depth value stored in the PDB 212.Depth tests are known in the art, and usually involve comparing thedepth value of a fragment with a corresponding depth value stored in adepth buffer. The result of a depth test depends upon a depth comparemode (DCM) in which the depth testing logic 210 is operating. Forexample, the DCM may be DCM_LESS_EQ in which the fragment will pass thedepth test if its depth value is less than or equal to the depth valuestored in the depth buffer 212 at the corresponding sample position.This is a common depth compare mode because this intuitively correspondsto testing whether a fragment is closer to a viewpoint than (i.e. infront of) previously processed fragments at the corresponding sampleposition when using the common convention that smaller depth valuesindicate that an object is closer, and larger depth values indicate thatan object is further away. As another example, the DCM may beDCM_GREATER in which the fragment will pass the depth test if its depthvalue is greater than the depth value stored in the depth buffer 212 atthe corresponding sample position. A person skilled in the art wouldunderstand that there are other depth compare modes (e.g. DCM_LESS,DCM_GREATER_EQ, DCM_EQUAL, DCM_ALWAYS and DCM_NEVER) and wouldunderstand how to implement the depth test according to the depthcompare mode which is currently set.

In step S308 the depth testing logic 210 determines whether the fragmentpassed the depth test. As described above, the PDB 212 stores depthvalues for resolved fragments, so if a fragment fails a depth testagainst the PDB 212 then it will not contribute to the final renderedimage and can be discarded. Therefore, if the fragment failed the depthtest the method passes from step S308 to step S310 in which the depthtesting logic 210 discards the fragment. It is noted that step S310might not be an active step. That is, the fragment may be discardedsimply by not storing its depth or identifier in any of the buffers inthe HSR module 204. Following step S310 the method passes to step S320in which it is determined whether there are any more fragments and/orprimitives to process in the depth testing logic 210, for which themethod of depth testing is to be repeated.

If the fragment passes the depth test against the PDB 212 then themethod passes from step S308 to step S312 in which the depth testinglogic 210 determines whether the fragment is a resolved fragment. Asdescribed above, opaque and translucent fragments are usually resolvedfragments because neither their presence nor depth values will bealtered by the fragment processing module 206, but punch throughfragments are unresolved fragments before the presence of the fragmentsis resolved because their presence may be altered by the fragmentprocessing module 206, e.g. they may depend upon an alpha test performedby the fragment processing module 206. Furthermore, o-depth fragmentsare unresolved fragments because their depth values may be altered bythe fragment processing module 206. If the fragment is a resolvedfragment then in step S314 the depth testing logic 210 uses the depthvalue of the fragment to update the PDB 212. That is, in step S314, thedepth testing logic 210 stores the depth value of the fragment in thePDB 212. This may involve overwriting a depth value that was previouslystored in the PDB 212 at the corresponding sample position.

As described above, the HSR module 204 includes three tag buffers 214 ₁to 214 ₃. At a given time, a first one of the tag buffers (e.g. tagbuffer 214 ₁) is configured to store primitive identifiers for thefragments whose depth values are stored in the PDB 212; a second one ofthe tag buffers (e.g. tag buffer 214 ₂) is configured to store primitiveidentifiers for the fragments whose depth values are stored in the SDB216; and a third one of the tag buffers (e.g. tag buffer 214 ₃) isconfigured to store primitive identifiers for fragments which are in theprocess of being flushed from the HSR module 204 to the fragmentprocessing module 206 which is described in more detail below. Thefunctions of the different tag buffers is not fixed and for example maychange dynamically as the system 200 processes primitives. For example,if, at a first point in time, the tag buffer 214 ₂ is storing tags forthe depth values stored in the SDB 216 and then the contents of the tagbuffer 214 ₂ are flushed to the fragment processing module 206 then thetag buffer 214 ₃ may be used to store tags for the depth values storedin the SDB 216 while the tag buffer 214 ₂ is being flushed.

In step S315, which follows step S314, a corresponding tag of theprimitive of which the fragment is a part is stored in the appropriatetag buffer (e.g. tag buffer 214 ₁ if that is the tag buffer which iscurrently storing tags corresponding to the depth values stored in thePDB 212).

Following step S315 the method passes to step S320 in which it isdetermined whether there are any more fragments and/or primitives toprocess in the depth testing logic 210, for which the method of depthtesting is to be repeated.

If the fragment is an unresolved fragment (e.g. if the fragment is apunch through fragment) then the method passes from step S312 to stepS316 in which the depth testing logic 210 uses the depth value of thefragment to update the SDB 216. That is, in step S316, the depth testinglogic 210 stores the depth value of the fragment in the SDB 216. In thisexample, step S316 should not involve overwriting a valid depth valuethat was previously stored in the SDB 216 because if there was already adepth value at the corresponding sample position in the SDB 216 then theindicator 218 would be set such that the method would have passed fromstep S304 to step S322 (which is described below) rather than passingfrom step S304 to step S306. Furthermore, in step S317, which followsstep S316, a corresponding tag of the primitive of which the fragment isa part is stored in the appropriate tag buffer (e.g. tag buffer 214 ₂ ifthat is the tag buffer which is currently storing tags corresponding tothe depth values stored in the SDB 216).

In step S318 the depth testing logic 210 sets the indicator for thefragment's sample position to indicate the SDB 216. This means thatsubsequent depth tests at the sample position will be performed usingthe depth value stored in the SDB 216. Following step S318 the methodpasses to step S320 in which it is determined whether there are any morefragments and/or primitives to process in the depth testing logic 210,for which the method of depth testing is to be repeated. If there aremore fragments which have been received at the depth testing logic 210for processing then the method passes back to step S304 and the methodcontinues for another fragment. Although the description of the methodshown in FIG. 3 implies that the method is performed for one fragmentand then subsequently the method is performed for the next fragment in aserial manner, in some examples multiple fragments may be processed inparallel to speed up the processing of large numbers (e.g. millions orbillions) of fragments which may be present in a scene.

If in step S304, the depth testing logic 210 determines that the SDB 216should be used for the depth test on a fragment then the method passesfrom step S304 to step S322. As described above, the indicator 218 willindicate the SDB 216 if there is a valid depth value stored in the SDB216 for the sample position of the fragment in question.

In step S322 the depth testing logic 210 performs a depth test on thefragment using the appropriate depth value stored in the SDB 216. Instep S324 the depth testing logic 210 determines whether the fragmentpassed the depth test. As described above, the SDB 216 stores depthvalues for unresolved fragments, so if a fragment fails a depth testagainst the SDB 216 then in step S326 the depth values of the SDB 216are resolved. This is because the depth test of step S322 was withrespect to an uncertain (i.e. unresolved) value, which needs to beresolved before a decision can be made about whether the currentfragment should be kept or discarded. It should be noted that the depthvalues in the SDB 216 may be invalidated by the fragment processingmodule 206 so it is possible that a fragment which fails a depth testagainst the SDB 216 could contribute to the final rendered image. Inorder to resolve the depth values of the SDB 216, the tags from the oneof the tag buffers 214 (e.g. tag buffer 214 ₂) which stores tagscorresponding to the depth values in the SDB 216 are flushed to thefragment processing module 206. When the flushed fragments are punchthrough fragments, the fragment processing module 206 can perform alphatests on the flushed fragments in order to determine which of the punchthrough fragments are present. In this way the depth values are resolvedby determining the presence or otherwise of the respective fragments,and the resolved depth values of the present fragments are fed back tothe depth testing logic 210. In step S328 the depth testing logic 210updates the depth values in the PDB 212 with the resolved depth valuesreceived from the fragment processing module 206. Since the depth valueshave been resolved and stored in the PDB 212, in step S330 theindicators for the sample positions from which the tags were flushed instep S326 are set to indicate the PDB 212 such that further depth testsat those sample positions are performed based on the resolved depthvalues in the PDB 212. The depth values in the SDB 216 can be discardedonce the depth values have been resolved and stored in the PDB 212.Alternatively, rather than discarding the depth values in the SDB 216,the depth values in the SDB 216 can be invalidated by setting theindicators for the appropriate sample positions to indicate the PDB 212.

The method can then proceed to step S306 in which a depth test isperformed for the fragment using the resolved depth values stored in thePDB 212. The method then proceeds as described above from step S306. Itis noted that the method may stall while the depth values from the SDB216 are resolved by the fragment processing module 206, but it is alsonoted that such stalls will occur less frequently than in the prior artsystem 100 described above. That is, in the system 100, a stall occurswhen an unresolved fragment passes a depth test against the depth buffer112. In contrast, in the system 200, when an unresolved fragment passesa depth test against the primary depth buffer 212 the depth value of theunresolved fragment is stored in the SDB 216 with no stall at thatpoint. If a subsequent opaque fragment passes the depth test against theSDB 216 then no stall will occur due to the unresolved fragment. If afragment fails a depth test against the SDB 216 a stall may occur, andas described in more detail below, even in that situation a stall may beavoided in some examples.

Returning to step S324, if the fragment passes the depth test againstthe SDB 216 then the method passes from step S324 to step S332 in whichthe depth testing logic 210 determines whether the fragment is aresolved fragment. If the fragment is an unresolved fragment (e.g. if itis a punch through fragment) then in step S333 the HSR module 204determines if a tag buffer is currently not in use and thereforeavailable. If there is an available tag buffer (e.g. tag buffer 214 ₃)then the method passes to step S335. However, if there is not anavailable tag buffer (e.g. all three of the tag buffers 214 ₁ to 214 ₃are currently in use) then one of the tag buffers is flushed to thefragment processing module 206. The tag buffer which is flushed may bechosen to be a tag buffer associated with the SDB 216. Furthermore, asan example, if more than one tag buffer is associated with the SDB 216to represent multiple layers then the tag buffer associated with the SDB216 and corresponding to the furthest of the layers may be chosen to beflushed in step S334. The flushing of a tag buffer in step S334 makesthe tag buffer available and then the method passes to step S335. Instep S335 the depth testing logic 210 uses the depth value of thefragment to update the SDB 216. That is, in step S335, the depth testinglogic 210 stores the depth value of the fragment in the SDB 216. Thismay involve overwriting a depth value that was previously stored in theSDB 216 at the corresponding sample position. In step S336, the tag ofthe fragment is written into the available tag buffer 214 (e.g. tagbuffer 214 ₃). By either holding the tag of the overwritten fragment ina tag buffer, or sending it to the fragment processing module 206 to beresolved, these steps ensure that the tag of the overwritten fragment,which may still contribute to the final image, is not discarded.Therefore, when step S336 has been performed, the depth values stored inthe SDB 216 are the depth values of the closest unresolved fragments,and the tags stored in the tag buffers are the tags for respectivelayers of fragments waiting to be resolved, thereby allowing the orderof the layers to be maintained. Following step S336 the method passes tostep S320 in which it is determined whether there are any more fragmentsand/or primitives to process in the depth testing logic 210, for whichthe method of depth testing is to be repeated.

If the fragment is a resolved fragment (e.g. if it is an opaque ortranslucent fragment) then the method passes from step S332 to step S337in which the depth testing logic 210 uses the depth value of thefragment to update the PDB 212. That is, in step S337, the depth testinglogic 210 stores the depth value of the fragment in the PDB 212. Thismay involve overwriting a depth value that was previously stored in thePDB 212 at the corresponding sample position. The depth value stored atthe corresponding sample position in the SDB 216 may be discarded sincethe current fragment has overwritten that depth value with a resolveddepth value. If the fragment is an opaque fragment then it willoverwrite the other fragments at the sample position so, in step S338 atag of the primitive of which the fragment is a part is stored in theappropriate tag buffer (e.g. tag buffer 214 ₁ if that is the tag bufferwhich is currently storing tags corresponding to the depth values storedin the PDB 212) and the tags in the other tag buffers are marked asinvalid. However, if the fragment is a translucent fragment then theunderlying fragments cannot simply be overwritten, so the tag of thetranslucent fragment is stored in a new tag buffer (e.g. tag buffer 214₃). If there are no new tag buffers available to store the tag of thecurrent fragment then one of the tag buffers 214 may be flushed therebymaking the tag buffer available to store the tag of the currentfragment. It is noted that any punch through fragment that is overdrawnby a translucent fragment can be treated as a “normal” translucentfragment (i.e. a resolved fragment) by the HSR module 204 because,having already been overdrawn, its depth/presence no longer needs to beresolved at the HSR module 204.

In step S339 the depth testing logic 210 sets the indicator for thefragment's sample position to indicate the PDB 212. This means thatsubsequent depth tests at the sample position will be performed usingthe depth value of the current fragment that was stored in the PDB 212in step S337. Following step S338 the method passes to step S320 inwhich it is determined whether there are any more fragments and/orprimitives to process in the depth testing logic 210, for which themethod of depth testing is to be repeated.

If it is determined in step S320 that there are currently no morefragments to process then the method passes to step S340 in which thetags stored in the tag buffers 214 are flushed to the fragmentprocessing module 206. The fragment processing module 206 can thenprocess the fragments indicated by the flushed tags, e.g. to applytexturing and/or shading to the fragments. The processing performed bythe HSR module 204 as shown in FIGS. 3a and 3b can be repeated whenfurther primitives are received at the HSR module 204.

It can therefore be seen that, in comparison with the prior art system100, the use of the secondary depth buffer 216 allows for a reduction inthe number times that the HSR module 204 needs to stall to wait forunresolved fragment to be resolved by the fragment processing module206. This also reduces the amount of processing (e.g. alpha testing)that the fragment processing module 206 needs to perform to resolve theunresolved fragments. This is because unresolved fragments, such aspunch through fragments, can have their depth values stored in the SDB216 such that they can be subsequently overwritten by opaque ortranslucent fragments without needing to resolve the presence of thepunch through fragments. In other words, in examples described herein,the HSR module 204 does not flush the tags of unresolved fragments tothe fragment processing module 206 until those unresolved fragments needto be resolved, thereby providing more opportunities for thoseunresolved fragments to be hidden by subsequent fragments such thatthose unresolved fragments do not need to be resolved. Furthermore, forpunch through fragments which pass the alpha test in the fragmentprocessing module 206, when the feedback is received at the HSR module204, the SDB 216 already has the depth values of the punch throughfragments stored therein, so there is no need to re-calculate the depthvalues of the fragments as would have been required by prior art system100.

FIG. 4 shows an example of the depth values of the PDB 212 and the SDB216 as well as depth values of incoming fragments, which helps toillustrate the operation of the system 200. In the example shown in FIG.4, the allowed depth values range from 0.0 to 1.0 and the viewpoint isshown on the left of FIG. 4 such that smaller depth values correspond tocloser depths. Depth values for a column of 32 sample positions areshown in FIG. 4. The dashed line 402 represents the depth values storedin the PDB 212 for the column of 32 sample positions at a particularpoint in time. The dashed line 404 represents the depth values stored inthe SDB 216 for the column of 32 sample positions at the same particularpoint in time. As shown by line 404 in FIG. 4, depth values for some,but not all, of the sample positions are stored in the SDB 216. Theindicators 218 will indicate the SDB 216 for the sample positions inwhich a depth value is stored in the SDB 216 and will indicate the PDB212 for sample positions in which a depth value is not stored in the SDB216. In the example shown in FIG. 4 the depth compare mode isDCM_LESS_EQ such that a fragment will pass a depth test if it has adepth value that is less than or equal to the depth value stored in adepth buffer.

A group of fragments 406 of a first primitive may be received at thedepth testing logic 210. As shown in FIG. 4, the sample positions of thefragments 406 are such that the indicators 218 will indicate that thedepth tests should be performed using the PDB 212. When the depthtesting logic 210 performs the depth tests on the fragments 406 in theDCM_LESS_EQ depth compare mode, the fragments 406 will fail the depthtests because their depth values are greater than the correspondingdepth values stored in the PDB 212, as shown by line 402. Therefore, thefragments 406 will be discarded since they will not contribute to thefinal image.

A different group of fragments 408 of a second primitive may be receivedat the depth testing logic 210 when the depth values stored in the PDB212 and the SDB 216 are shown by the lines 402 and 404 respectively. Asshown in FIG. 4, the sample positions of the fragments 408 are such thatthe indicators 218 will indicate that the depth tests should beperformed using the PDB 212. When the depth testing logic 210 performsthe depth tests on the fragments 408 in the DCM_LESS_EQ depth comparemode, the fragments 408 will pass the depth tests because their depthvalues are less than the corresponding depth values stored in the PDB212, as shown by line 402. If the fragments 408 are opaque ortranslucent (i.e. if they are resolved fragments) then the depth valuesof the fragments 408 will be written into the PDB 212 whereas if thefragments 408 are punch through (i.e. if they are unresolved fragments)then the depth values of the fragments 408 will be written into the SDB216 and the indicators 218 for the sample positions of the fragments 408will be set to indicate the SDB 216. The tags for the fragments 408 willbe written into the appropriate one of the tag buffers 214.

A different group of fragments 410 of a third primitive may be receivedat the depth testing logic 210 when the depth values stored in the PDB212 and the SDB 216 are shown by the lines 402 and 404 respectively. Asshown in FIG. 4, the sample positions of the fragments 410 are such thatthe indicators 218 will indicate that the depth tests should beperformed using the SDB 216. When the depth testing logic 210 performsthe depth tests on the fragments 410 in the DCM_LESS_EQ depth comparemode, the fragments 410 will fail the depth tests because their depthvalues are greater than the corresponding depth values stored in the SDB216, as shown by line 404. Therefore, the depth values in the SDB 216are resolved by flushing the corresponding fragments of the SDB 216 tothe fragment processing module 206. When the resolved depth values arereceived from the fragment processing module 206, the depth testinglogic 210 updates the PDB 212 using the resolved depth values and thefragments 410 are re-tested against the depth values in the PDB 212. Ifpunch through fragments are resolved by the fragment processing module206 to be present then the corresponding depth values of the PDB 212 areupdated to have the depth shown by line 404, but for punch throughfragments which are not present the corresponding depth values of thePDB 212 remain at line 402. The depths of o-depth fragments may beresolved by the fragment processing module 206 to be different to thoseshown by line 404, so a comparison between the resolved o-depth valuesand the depth values in the PDB 212 (shown by line 402) may be performedto determine how to update the depth values in the PDB 212 accordingly,e.g. by updating the depth values to be the lesser of the resolvedo-depth values and the previous depth values in the PDB 212 (shown byline 402). The fragments 410 will fail the depth test against the PDB212 and hence will be discarded.

A different group of fragments 412 of a fourth primitive may be receivedat the depth testing logic 210 when the depth values stored in the PDB212 and the SDB 216 are shown by the lines 402 and 404 respectively. Asshown in FIG. 4, the sample positions of the fragments 412 are such thatthe indicators 218 will indicate that the depth tests should beperformed using the SDB 216. When the depth testing logic 210 performsthe depth tests on the fragments 412 in the DCM_LESS_EQ depth comparemode, the fragments 412 will fail the depth tests because their depthvalues are greater than the corresponding depth values stored in the SDB216, as shown by line 404. Therefore, the depth values in the SDB 216are resolved by flushing the corresponding fragments of the SDB 216 tothe fragment processing module 206. When the resolved depth values arereceived from the fragment processing module 206, the depth testinglogic 210 updates the PDB 212 with the resolved depth values and thefragments 412 are re-tested against the depth values in the PDB 212.Depending on the results of the resolving of the depth values from theSDB 216, some or all of the fragments 412 may pass the depth testsagainst the PDB 212, while the remainder may fail. Fragments 412 thatfail the depth test against the PDB 212 are discarded and fragments 412that pass the depth test are not discarded. As described above, iffragments 412 that pass the depth test are opaque or translucent (i.e.if they are resolved fragments) then the depth values of the fragments412 will be written into the PDB 212 and the indicators 218 for thesample positions of the fragments 408 will be set to indicate the PDB216, whereas for fragments 412 that pass the depth test and are punchthrough (i.e. if they are unresolved fragments) then the depth values ofthe fragments 412 will be written into the SDB 216. The tags for thefragments 412 will be written into the appropriate one of the tagbuffers 214 if the fragments 412 pass the depth test.

A different group of fragments 414 of a fifth primitive may be receivedat the depth testing logic 210 when the depth values stored in the PDB212 and the SDB 216 are shown by the lines 402 and 404 respectively. Asshown in FIG. 4, the sample positions of the fragments 414 are such thatthe indicators 218 will indicate that the depth tests should beperformed using the SDB 216. When the depth testing logic 210 performsthe depth tests on the fragments 414 in the DCM_LESS_EQ depth comparemode, the fragments 414 will pass the depth tests because their depthvalues are less than the corresponding depth values stored in the SDB216, as shown by line 404. If the fragments 414 are resolved fragments(e.g. if they are opaque or translucent fragments) then their depthvalues are written into the PDB 212 and the indicators for thecorresponding sample positions are set to indicate that subsequent depthtests should be performed using the PDB 212. If the resolved fragments414 are opaque then the depth values in the SDB 216 for thecorresponding sample positions could be discarded and the tags for theoverwritten fragments could be discarded from the relevant tag buffer.In this way the overwritten fragments would not need to be flushed tothe fragment processing module 206, which can reduce stalling andunnecessary fragment processing in the system 200. If the resolvedfragments 414 are translucent then the fragments which lie behind thefragments 414 may be flushed to the fragment processing module 206 ifnecessary to ensure that there is an available tag buffer to store tagsfor the fragments 414. If the fragments 414 are unresolved fragmentsthen their depth values are stored in the SDB 216. The tags for thefragments 414 will be written into one of the tag buffers 214. Asdescribed above, tag buffers may be used to store tags of differentlayers of fragments, and if there is not an available tag buffer tostore the tags for the fragments 414, one of the tag buffers may need tobe flushed so that it can be used to store the tags for the fragments414.

In the examples described above when a fragment fails a depth testagainst the SDB 216 (e.g. as determined in step 324) then the depthvalues stored in the SDB 216 and/or presence of the respective fragmentsare resolved and used to update the PDB 212, and a second depth test isthen performed on the fragment using the appropriate depth value storedin the PDB 212 after the updating of the depth values in the PDB 212 (insteps S326, S328 and S306). However, in other examples, if a fragmentfails a depth test performed using a depth value stored in the SDB 216,then the depth testing logic 210 may perform a second depth test on thefragment using the appropriate depth value stored in the PDB 212. Thiscould be appropriate for fragments 410 and 412 shown in FIG. 4. If thefragment fails the depth test against the PDB 212 then the fragmentcould be discarded (e.g. for fragments 410). This avoids the need toresolve the depth values in the SDB 216 when the fragments 410 fail thedepth test against the SDB 216, but it may incur extra depth testing inthe HSR module 204. In particular, if the fragment passes the depth testagainst the PDB 212 after failing the depth test against the SDB 216(e.g. fragments 412 would pass the depth test against the PDB 212) thenthe depth values stored in the SDB 216 can be resolved and used toupdate the depth values in the PDB 212. Then a third depth test could beperformed on the fragment using the appropriate depth value stored inthe PDB 212 after the updating of the depth values in the PDB 212.

In the methods described above with reference to FIG. 3, a stall occursin the processing of opaque and translucent fragments that are found tolie behind punch through fragments (that is, they fail the depth testagainst the SDB at S324), whilst the depth values of the punch throughfragments are resolved. In other examples, it is possible to remove thisstall, as described below. In these examples, when a fragment fails adepth test against the SDB 216 then the fragments in the tag bufferassociated with the SDB 216 are flushed to the fragment processingmodule 206. Rather than stalling to wait for the fragment processingmodule 206 to process the flushed fragments, the values in the SDB 216are cleared and the indicators are all set to indicate the PDB 212 andthen depth testing continues for further incoming fragments, and if thedepth values pass the depth tests they are written into the SDB 216 (notthe PDB 212). This is how the HSR module 204 processes opaque andtranslucent fragments (i.e. fragments which would normally be consideredto be resolved fragments). The results are written into the SDB 216because until the feedback is returned from the fragment processingmodule 206 the visibility of a fragment which passes a depth test is notknown, and therefore the incoming fragments may be considered“unresolved” fragments (i.e. they have unresolved visibility) for whichthe depth values are stored in the SDB 216 as described herein. Thismeans that while the HSR module 204 is waiting for the feedback from thefragment processing module 206 any incoming fragments are unresolvedfragments because their visibility is unresolved. When the feedback isreceived from the fragment processing module 206, the returned resolveddepth values are compared with those now in the SDB 216 to determineresolved depth values which can then be stored in the PDB 212 and therelevant tags can be stored in the tag buffer 214 which is currentlyassociated with the PDB 212.

However, if fragments which would normally be considered to beunresolved fragments (e.g. punch through or o-depth fragments) arereceived at the depth testing logic 210 before the feedback from thefragment processing module 206 is received then the depth testing logic210 will stall until the feedback is received. Therefore, a stall can beprevented while waiting for feedback if opaque or translucent fragmentsare received at the depth testing logic 210, but a stall is notprevented if a punch through or o-depth fragment is received whilewaiting for feedback.

In the examples described above there are three tag buffers 214 ₁, 214 ₂and 214 ₃. In other examples there may be more than three tag bufferswhich allows for more layers of fragments to be stored before tags areflushed to the fragment processing module 206. This may reduce thenumber of flushes that are performed since there would be moreopportunity for opaque fragments to overwrite fragments before they areflushed. However, the use of more tag buffers would require more memoryon the GPU 202, so when choosing the number of tag buffers there is atrade-off between reducing the number of flushes and reducing the memoryrequirements on the GPU 202.

Punch through fragments may be further divided into two types: (i)opaque punch through (OPT) fragments which are either present and fullyopaque or not present, or (ii) translucent punch through (TPT) fragmentswhich can be present or not present but for which the present fragmentsmay be translucent (i.e. not fully opaque). As described below, wheremultiple layers of overlapping OPT fragments are stored in multiple tagbuffers, it is possible to control the order in which the tag buffersare flushed in a non-conventional way to gain some efficiency. If alocation within the rendering space has a depth value stored in the SDB216 when a new OPT fragment is determined to be in front of thecurrently stored depth (in the SDB 216), then rather than flushing thefragments from the tag buffer associated with the SDB 216 it is possibleto use additional tag buffers to store layers of OPT fragments. Aper-fragment front-most tag buffer ID can be maintained (e.g. stored inan array) and used to determine which OPT fragments are the front most.The front-most OPT fragments can be flushed to the fragment processingmodule 206 first (contrary to rigidly following submission order as isconventional). If the front most OPT fragment at a sample position isdetermined to be present by the alpha test then the fragments at thesame position in the underlying layers can be discarded. This methodcannot be used for punch through objects which allow for translucency,as it is necessary to process all translucent fragments, in the orderthat they are submitted, but for OPT objects this method provides moreopportunity for discarding fragments without unnecessarily processingthem in the fragment processing module 206. That is, processing thefront most OPT fragments first allows fragments that are overdrawn bysubsequent fragments to be rejected i.e. not sent the fragmentprocessing module 206.

When an OPT fragment is determined to be visible with respect to the PDB212 a new tag buffer should be allocated into which all fragments forthe new OPT object are written. Each fragment that passes the depth testagainst the PDB 212 is tested against the SDB 216. If a fragment alsopasses the depth test against the SDB 216 then the SDB 216 is updatedwith the depth of the new fragment and the front-most tag buffer ID forthe fragment is updated to point to the newly allocated tag buffer.

When it is determined to be necessary to flush tag buffers to thefragment processing module 206, for example when no more tag buffers areavailable, the per-fragment front-most tag buffer IDs are used todetermine which fragments should be sent to the fragment processingmodule 206 first. Once the front most fragments have been sent anyremaining fragments can be submitted if necessary (e.g. to make a tagbuffer available) a tag buffer at a time in the order in which the tagbuffers were allocated i.e. in primitive submission order. Preferably,the HSR module 204 waits for the depths to be resolved for thefront-most tags before submitting any remaining fragments.

In the examples described above, the PDB 212 and the SDB 214 relate tothe same sample positions of the rendering space, e.g. they relate tothe same tile within a tile-based system. Some tile-based systems may becapable of having multiple tiles in flight, in which case a respectivepair of depth buffers, i.e. a primary depth buffer and a secondary depthbuffer, would be used for each of the tiles that can be simultaneously“in flight” within the HSR module 204. That is, for each currentlyactive tile, a primary depth buffer is used to store depth values ofresolved fragments and a secondary depth buffer is used to store depthvalues of unresolved fragments in accordance with the principles of themethods described herein.

Generally, any of the functions, methods, techniques or componentsdescribed above (e.g. the depth testing logic 210 and/or the fragmentprocessing module 206) can be implemented in modules using software,firmware, hardware (e.g., fixed logic circuitry), or any combination ofthese implementations. The terms “module,” “functionality,” “component”,“block”, “unit” and “logic” are used herein to generally representsoftware, firmware, hardware, or any combination thereof.

In the case of a software implementation, the module, functionality,component, unit or logic represents program code that performs specifiedtasks when executed on a processor (e.g. one or more CPUs). In oneexample, the methods described may be performed by a computer configuredwith software in machine readable form stored on a computer-readablemedium. One such configuration of a computer-readable medium is signalbearing medium and thus is configured to transmit the instructions (e.g.as a carrier wave) to the computing device, such as via a network. Thecomputer-readable medium may also be configured as a non-transitorycomputer-readable storage medium and thus is not a signal bearingmedium. Examples of a computer-readable storage medium include arandom-access memory (RAM), read-only memory (ROM), an optical disc,flash memory, hard disk memory, and other memory devices that may usemagnetic, optical, and other techniques to store instructions or otherdata and that can be accessed by a machine.

The software may be in the form of a computer program comprisingcomputer program code for configuring a computer to perform theconstituent portions of described methods or in the form of a computerprogram comprising computer program code means adapted to perform allthe steps of any of the methods described herein when the program is runon a computer and where the computer program may be embodied on acomputer readable medium. The program code can be stored in one or morecomputer readable media. The features of the techniques described hereinare platform-independent, meaning that the techniques may be implementedon a variety of computing platforms having a variety of processors.

Those skilled in the art will also realize that all, or a portion of thefunctionality, techniques or methods may be carried out by a dedicatedcircuit, an application-specific integrated circuit, a programmablelogic array, a field-programmable gate array, or the like. For example,the module, functionality, component, unit or logic (e.g. the depthtesting logic 210 and/or the fragment processing module 206) maycomprise hardware in the form of circuitry. Such circuitry may includetransistors and/or other hardware elements available in a manufacturingprocess. Such transistors and/or other elements may be used to formcircuitry or structures that implement and/or contain memory, such asregisters, flip flops, or latches, logical operators, such as Booleanoperations, mathematical operators, such as adders, multipliers, orshifters, and interconnects, by way of example. Such elements may beprovided as custom circuits or standard cell libraries, macros, or atother levels of abstraction. Such elements may be interconnected in aspecific arrangement. The module, functionality, component, unit orlogic (e.g. the depth testing logic 210 and/or the fragment processingmodule 206) may include circuitry that is fixed function and circuitrythat can be programmed to perform a function or functions; suchprogramming may be provided from a firmware or software update orcontrol mechanism. In an example, hardware logic has circuitry thatimplements a fixed function operation, state machine or process.

It is also intended to encompass software which “describes” or definesthe configuration of hardware that implements a module, functionality,component, unit or logic (e.g. the components of the graphics processingsystem 200) described above, such as HDL (hardware description language)software, as is used for designing integrated circuits, or forconfiguring programmable chips, to carry out desired functions. That is,there may be provided a computer readable storage medium having encodedthereon computer readable program code in the form of an integratedcircuit definition dataset that when processed in an integrated circuitmanufacturing system configures the system to manufacture a graphicsprocessing system configured to perform any of the methods describedherein, or to manufacture a graphics processing system comprising anyapparatus described herein. The IC definition dataset may be in the formof computer code, e.g. written in a suitable HDL such asregister-transfer level (RTL) code. An example of processing anintegrated circuit definition dataset at an integrated circuitmanufacturing system so as to configure the system to manufacture agraphics processing system will now be described with respect to FIG. 5.

FIG. 5 shows an example of an integrated circuit (IC) manufacturingsystem 502 which comprises a layout processing system 504 and anintegrated circuit generation system 506. The IC manufacturing system502 is configured to receive an IC definition dataset (e.g. defining agraphics processing system as described in any of the examples herein),process the IC definition dataset, and generate an IC according to theIC definition dataset (e.g. which embodies a graphics processing systemas described in any of the examples herein). The processing of the ICdefinition dataset configures the IC manufacturing system 502 tomanufacture an integrated circuit embodying a graphics processing unitas described in any of the examples herein. More specifically, thelayout processing system 504 is configured to receive and process the ICdefinition dataset to determine a circuit layout. Methods of determininga circuit layout from an IC definition dataset are known in the art, andfor example may involve synthesising RTL code to determine a gate levelrepresentation of a circuit to be generated, e.g. in terms of logicalcomponents (e.g. NAND, NOR, AND, OR, MUX and FLIP-FLOP components). Acircuit layout can be determined from the gate level representation ofthe circuit by determining positional information for the logicalcomponents. This may be done automatically or with user involvement inorder to optimise the circuit layout. When the layout processing system504 has determined the circuit layout it may output a circuit layoutdefinition to the IC generation system 506. The IC generation system 506generates an IC according to the circuit layout definition, as is knownin the art. For example, the IC generation system 506 may implement asemiconductor device fabrication process to generate the IC, which mayinvolve a multiple-step sequence of photo lithographic and chemicalprocessing steps during which electronic circuits are gradually createdon a wafer made of semiconducting material. The circuit layoutdefinition may be in the form of a mask which can be used in alithographic process for generating an IC according to the circuitdefinition. Alternatively, the circuit layout definition provided to theIC generation system 506 may be in the form of computer-readable codewhich the IC generation system 506 can use to form a suitable mask foruse in generating an IC. The different processes performed by the ICmanufacturing system 502 may be implemented all in one location, e.g. byone party. Alternatively, the IC manufacturing system 502 may be adistributed system such that some of the processes may be performed atdifferent locations, and may be performed by different parties. Forexample, some of the stages of: (i) synthesising RTL code representingthe IC definition dataset to form a gate level representation of acircuit to be generated, (ii) generating a circuit layout based on thegate level representation, (iii) forming a mask in accordance with thecircuit layout, and (iv) fabricating an integrated circuit using themask, may be performed in different locations and/or by differentparties.

In other examples, processing of the integrated circuit definitiondataset at an integrated circuit manufacturing system may configure thesystem to manufacture a graphics processing system without the ICdefinition dataset being processed so as to determine a circuit layout.For instance, an integrated circuit definition dataset may define theconfiguration of a reconfigurable processor, such as an FPGA, and theprocessing of that dataset may configure an IC manufacturing system togenerate a reconfigurable processor having that defined configuration(e.g. by loading configuration data to the FPGA).

In some examples, an integrated circuit definition dataset could includesoftware which runs on hardware defined by the dataset or in combinationwith hardware defined by the dataset. In the example shown in FIG. 5,the IC generation system may further be configured by an integratedcircuit definition dataset to, on manufacturing an integrated circuit,load firmware onto that integrated circuit in accordance with programcode defined at the integrated circuit definition dataset or otherwiseprovide program code with the integrated circuit for use with theintegrated circuit.

The term ‘processor’ and ‘computer’ are used herein to refer to anydevice, or portion thereof, with processing capability such that it canexecute instructions, or a dedicated circuit capable of carrying out allor a portion of the functionality or methods, or any combinationthereof.

Although the subject matter has been described in language specific tostructural features and/or methodological acts, it is to be understoodthat the subject matter defined in the appended claims is notnecessarily limited to the specific features or acts described above.Rather, the specific features and acts described above are disclosed asexample forms of implementing the claims. It will be understood that thebenefits and advantages described above may relate to one example or mayrelate to several examples.

Any range or value given herein may be extended or altered withoutlosing the effect sought, as will be apparent to the skilled person. Thesteps of the methods described herein may be carried out in any suitableorder, or simultaneously where appropriate. Aspects of any of theexamples described above may be combined with aspects of any of theother examples described to form further examples without losing theeffect sought.

1. A graphics processing system comprising: a first depth bufferconfigured to store depth values for resolved fragments for a pluralityof sample positions within a rendering space of the graphics processingsystem; a second depth buffer configured to store depth values forunresolved fragments for the sample positions; and depth testing logicconfigured to receive primitive data relating to primitives and toperform depth tests on fragments of the primitives using depth valuesstored in at least one of the depth buffers; wherein the graphicsprocessing system is configured to: (i) store, in the first depthbuffer, the depth value of a fragment which passes a depth test if thefragment is a resolved fragment, and (ii) store, in the second depthbuffer, the depth value of a fragment which passes a depth test if thefragment is an unresolved fragment.
 2. The graphics processing system ofclaim 1, wherein a fragment is unresolved if one or more of: (i) thedepth of the fragment is not resolved, (ii) the presence of the fragmentis not resolved, or (iii) the visibility of the fragment is notresolved; and wherein a fragment is resolved if the depth, presence andvisibility of the fragment are resolved.
 3. The graphics processingsystem of claim 1 wherein fragments associated with a punch throughobject type are unresolved fragments before the presence of thefragments is resolved.
 4. The graphics processing system of claim 1wherein fragments associated with an opaque object type or a translucentobject type are resolved fragments unless the visibility of the fragmentis not resolved.
 5. The graphics processing system of claim 1 whereinthe depth testing logic is configured to maintain a set of indicatorswhich indicate, for each of the sample positions, which of the depthbuffers to use for the depth tests.
 6. The graphics processing system ofclaim 5 wherein each of the indicators is associated with a respectiveone of the sample positions.
 7. The graphics processing system of claim5 wherein the graphics processing system is configured to initialise theindicators to indicate the first depth buffer.
 8. The graphicsprocessing system of claim 5 wherein the depth testing logic isconfigured to set the indicator for a sample position to indicate thesecond depth buffer if an unresolved fragment at the sample positionpasses a depth test.
 9. The graphics processing system of claim 5wherein the depth testing logic is configured to set the indicator for asample position to indicate the first depth buffer if a resolvedfragment at the sample position passes a depth test performed using adepth value stored in the second depth buffer.
 10. The graphicsprocessing system of claim 1 wherein the depth testing logic isconfigured to discard a fragment which fails a depth test performedusing a depth value stored in the first depth buffer.
 11. The graphicsprocessing system of claim 1 further configured to resolve the fragmentsof the second depth buffer if a particular fragment fails a depth testperformed using a depth value stored in the second depth buffer, whereinthe depth testing logic is configured to: use the depth values of theresolved fragments to update the depth values in the first depth buffer;and perform a second depth test on the particular fragment using theappropriate depth value stored in the first depth buffer after theupdating of the depth values in the first depth buffer.
 12. The graphicsprocessing system of claim 1 further configured such that, if aparticular fragment fails a depth test performed using a depth valuestored in the second depth buffer, the depth testing logic is configuredto: perform a second depth test on the particular fragment using theappropriate depth value stored in the first depth buffer; wherein thegraphics processing system is configured to, if the particular fragmentpasses the second depth test: (i) resolve the fragments of the seconddepth buffer, (ii) use the depth values of the resolved fragments toupdate the depth values in the first depth buffer, and (iii) perform athird depth test on the particular fragment using the appropriate depthvalue stored in the first depth buffer after the updating of the depthvalues in the first depth buffer; and wherein the graphics processingsystem is configured to discard the particular fragment if theparticular fragment fails the second depth test.
 13. The graphicsprocessing system of claim 11 wherein while the fragments of the seconddepth buffer are being resolved, the depth testing logic is configuredto: clear the depth values from the second depth buffer; and continuedepth testing for fragments of primitives relating to received primitivedata, wherein if a resolved fragment passes a depth test its depth valueis written into the second depth buffer; wherein when the fragments ofthe second depth buffer have been resolved, the depth testing logic isconfigured to compare the depth values of the resolved fragments withthose in the second depth buffer and to update the first depth bufferwith resolved depth values accordingly.
 14. The graphics processingsystem of claim 1 further comprising a set of at least three tagbuffers, including: a first one of the tag buffers which is configuredto store primitive identifiers for the fragments whose depth values arestored in the first depth buffer; a second one of the tag buffers whichis configured to store primitive identifiers for the fragments whosedepth values are stored in the second depth buffer; and a third one ofthe tag buffers which is configured to store primitive identifiers forfragments which are in the process of being flushed.
 15. The graphicsprocessing system of claim 1 wherein multiple tag buffers are configuredto store primitive identifiers for multiple layers of opaque punchthrough fragments, wherein the graphics processing system is configuredto control the order in which the multiple tag buffers are flushed suchthat the front-most opaque punch through fragments are flushed beforeunderlying layers of the opaque punch through fragments.
 16. Thegraphics processing system of claim 1 wherein the graphics processingsystem is a deferred rendering system which comprises a fragmentprocessing module for performing one or both of shading and texturing onfragments, wherein the fragment processing module is arranged to act onfragments after the depth testing logic, and wherein the unresolvedfragments can be resolved by the fragment processing module.
 17. Thegraphics processing system of claim 1 wherein the graphics processingsystem is a tile-based graphics system in which the rendering spacecomprises one or more tiles, and wherein each of the depth buffers isconfigured to store depth values for sample positions within one tile ata time.
 18. A method of processing primitives in a graphics processingsystem which comprises a first depth buffer configured to store depthvalues for resolved fragments for a plurality of sample positions withina rendering space of the graphics processing system, and a second depthbuffer configured to store depth values for unresolved fragments for thesample positions, the method comprising: receiving primitive datarelating to primitives at depth testing logic of the graphics processingsystem; performing depth tests on fragments of the primitives usingdepth values stored in at least one of the depth buffers; and storingthe depth value of a fragment which passes a depth test in one of thedepth buffers wherein, if the fragment is a resolved fragment then thedepth value of the fragment is stored in the first depth buffer, and ifthe fragment is an unresolved fragment then the depth value of thefragment is stored in the second depth buffer.
 19. A non-transitorycomputer readable storage medium having stored thereon processorexecutable instructions that when executed cause at least one processorto process primitives in a graphics processing system which comprises afirst depth buffer configured to store depth values for resolvedfragments for a plurality of sample positions within a rendering spaceof the graphics processing system, and a second depth buffer configuredto store depth values for unresolved fragments for the sample positions,the processing of the primitives comprising: receiving primitive datarelating to primitives at depth testing logic of the graphics processingsystem; performing depth tests on fragments of the primitives usingdepth values stored in at least one of the depth buffers; and storingthe depth value of a fragment which passes a depth test in one of thedepth buffers wherein, if the fragment is a resolved fragment then thedepth value of the fragment is stored in the first depth buffer, and ifthe fragment is an unresolved fragment then the depth value of thefragment is stored in the second depth buffer.
 20. A non-transitorycomputer readable storage medium having stored thereon an integratedcircuit definition dataset that, when processed in an integrated circuitmanufacturing system, configures the system to manufacture a graphicsprocessing system comprising: a first depth buffer configured to storedepth values for resolved fragments for a plurality of sample positionswithin a rendering space of the graphics processing system; a seconddepth buffer configured to store depth values for unresolved fragmentsfor the sample positions; and depth testing logic configured to receiveprimitive data relating to primitives and to perform depth tests onfragments of the primitives using depth values stored in at least one ofthe depth buffers; wherein the graphics processing system is configuredto: (i) store, in the first depth buffer, the depth value of a fragmentwhich passes a depth test if the fragment is a resolved fragment, and(ii) store, in the second depth buffer, the depth value of a fragmentwhich passes a depth test if the fragment is an unresolved fragment.